//
//  AXHomeNcpscFiveCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/22.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXHomeNcpscFiveCell.h"
#import "AXHomeNcpscFiveCollectionCell.h"

@interface AXHomeNcpscFiveCell ()<UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;

@end

@implementation AXHomeNcpscFiveCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
       
    }
    return self;
}

- (void)creatView {
    
    /** 背景图片 */
    self.bgImageView = [[UIImageView alloc]init];
    self.bgImageView.userInteractionEnabled = YES;
    self.bgImageView.image = [UIImage imageNamed:@"blue"];
    [self.contentView addSubview:self.bgImageView];
    
    /** 背景图片 */
    self.bgImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 10)
    .widthIs(SCREEN_WIDTH-20)
    .heightIs(130);
    
    self.label = [[UILabel alloc]init];
    self.label.font = FONT_FOURTEEN;
    self.label.text = @"人气榜单";
    self.label.textColor = COLOR_GREEN;
    [self.bgImageView addSubview:self.label];
    
    self.label.sd_layout
    .leftSpaceToView(self.bgImageView, 10)
    .topSpaceToView(self.bgImageView, 0)
    .widthIs(80)
    .heightIs(BTN_HEIGHT);
    

    /** collectionView */
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH-30)/2.0, 130);
    /** 最小行间距 */
    flowLayout.minimumLineSpacing = 0;
    /** 最小列间距 */
    flowLayout.minimumInteritemSpacing = 0;
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 130*2) collectionViewLayout:flowLayout];
    //wangherun666
   // self.collectionView.contentInset = UIEdgeInsetsMake(8, 8, 8, 8);
    self.collectionView.backgroundColor = [UIColor clearColor];
    [self.collectionView registerClass:[AXHomeNcpscFiveCollectionCell class] forCellWithReuseIdentifier:[AXHomeNcpscFiveCollectionCell reuseID]];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.bgImageView addSubview:self.collectionView];
    
    
}




#pragma mark - Collection View Data Source
/** 定义展示的section的个数 */

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    
    return 1;
}
/** 定义展示的collectionCell的个数 */
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    
    return 2;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    AXHomeNcpscFiveCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[AXHomeNcpscFiveCollectionCell reuseID] forIndexPath:indexPath];
   
    
    
    return cell;
}


#pragma mark - collectionViewDelegateFlowLayout

/** UICollectionView被选中时的方法 */


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    if (self.tapButtonClickedBlock) {
        self.tapButtonClickedBlock(indexPath.row);
    }
    
}


#pragma mark - Setter & Getter

//- (NSMutableArray<ZXResourceModel *> *)modelsArray {
//    if (!_modelsArray) {
//        _modelsArray = [NSMutableArray<ZXResourceModel *> array];
//    }
//    return _modelsArray;
//}




@end
